<%@ Page Language="C#" AutoEventWireup="true" CodeFile="AccessOptions.aspx.cs" Inherits="Doctor_AccessOptions" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Select Options</title>

    <link href="../includes/stylesheet.css" rel="stylesheet" />
    <script>
        function setData()
        {
            var url ="<%=strWhich%>";
            var ctl = "<%=strCtl%>";
            var lbl = "<%=strLbl%>";
            var op = "";
            var str = "";
            var pdoc = window.opener.document;
//            alert(ctl);
//            alert(lbl);
            str = getSelectedValue(true,false,"");
            if(url.indexOf("2")>=0)//Medical School
            {                
                pdoc.getElementById(ctl).value = str.split("~")[0];
                pdoc.getElementById(lbl).innerText = str.split("~")[1];
            }
            window.close(); 
        }
        function getSelectedValue(isRadio,isReturnMultipleIdValues,valu)
        {      
            var op = "";
            var IDs = "";
            var vals = "";
            
            if(isRadio)
            {
                if(document.forms[0].opSelect.length != null)
                {
                    for(i=0;i<document.forms[0].opSelect.length;i++)
                        if(document.forms[0].opSelect[i].checked)
                        {
                            op=document.forms[0].opSelect[i].value;
                            break;
                        }
                }
                else
                    op=document.forms[0].opSelect.value;
            }
            else if(!isReturnMultipleIdValues) //return string values seperated by <BR>
            {
            
                if(document.forms[0].opSelect.length != null)
                {
                    for(i=0;i<document.forms[0].opSelect.length;i++)
                        if(document.forms[0].opSelect[i].checked)
                        {
                            if(valu.indexOf(document.forms[0].opSelect[i].value)<0)
                            {
                                if(op.length!=0)
                                    op += "<BR>";
                                op += document.forms[0].opSelect[i].value;
                            }
                        }
                }
                else
                    op=document.forms[0].opSelect.value;
                if(valu.length!=0 && valu != "NONE")
                    op = "<BR>" + op;
            }
            else if(isReturnMultipleIdValues) //return in the format ID1,ID2,ID3~val1<BR>val2<BR>val3
            {
                var val = valu.split('~')[1];
                if(document.forms[0].opSelect.length != null)
                {
                    for(i=0;i<document.forms[0].opSelect.length;i++)
                    {
                        if(document.forms[0].opSelect[i].checked)
                        {
                            if(val.indexOf(document.forms[0].opSelect[i].value.split('~')[1]) < 0)//remove duplicates 
                            {
                                 //Concat IDs and values seperately
                                 if(IDs.length == 0)
                                    IDs = document.forms[0].opSelect[i].value.split('~')[0];
                                 else
                                    IDs += "," + document.forms[0].opSelect[i].value.split('~')[0];
                                 if(vals.length == 0)
                                    vals = document.forms[0].opSelect[i].value.split('~')[1];
                                 else
                                    vals += "<BR>" + document.forms[0].opSelect[i].value.split('~')[1];
                            }
                        }
                     }
                }
                else
                {
                    IDs = document.forms[0].opSelect.value.split('~')[0];
                    vals = document.forms[0].opSelect.value.split('~')[1];
                }
                if(valu.length!=0 && valu != "~NONE")
                {
                   op = valu.split('~')[0] + "," + IDs + "~" + valu.split('~')[1] + "<BR>" + vals;
                }
                else
                   op = IDs + "~" + vals;
            }
            return op;
        }
    </script>
</head>
<body onload="if(document.forms[0].btnSelectTop != null) document.forms[0].btnSelectTop.style.display='inline'">
    <form id="form1" runat="server">
    <div style="padding:5px">
    <asp:Label ID="lblPageHeader" runat="server" Font-Bold="true" CssClass="page-heading" /><br />
    <asp:Label ID="lblHelpHint" runat="server" Font-Size="X-Small" />
    <br /><br />
    <asp:Panel ID="pnlAlpha" runat="server">
    <a href="AccessOptions.aspx?sortby=a&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">A</a>
    <a href="AccessOptions.aspx?sortby=b&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">B</a>
    <a href="AccessOptions.aspx?sortby=c&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">C</a>
    <a href="AccessOptions.aspx?sortby=d&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">D</a>
    <a href="AccessOptions.aspx?sortby=e&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">E</a>
    <a href="AccessOptions.aspx?sortby=f&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">F</a>
    <a href="AccessOptions.aspx?sortby=g&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">G</a>
    <a href="AccessOptions.aspx?sortby=h&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">H</a>
    <a href="AccessOptions.aspx?sortby=i&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">I</a>
    <a href="AccessOptions.aspx?sortby=j&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">J</a>
    <a href="AccessOptions.aspx?sortby=k&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">K</a>
    <a href="AccessOptions.aspx?sortby=l&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">L</a>
    <a href="AccessOptions.aspx?sortby=m&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">M</a>
    <a href="AccessOptions.aspx?sortby=n&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">N</a>
    <a href="AccessOptions.aspx?sortby=o&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">O</a>
    <a href="AccessOptions.aspx?sortby=p&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">P</a>
    <a href="AccessOptions.aspx?sortby=q&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">Q</a>
    <a href="AccessOptions.aspx?sortby=r&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">R</a>
    <a href="AccessOptions.aspx?sortby=s&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">S</a>
    <a href="AccessOptions.aspx?sortby=t&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">T</a>
    <a href="AccessOptions.aspx?sortby=u&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">U</a>
    <a href="AccessOptions.aspx?sortby=v&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">V</a>
    <a href="AccessOptions.aspx?sortby=w&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">W</a>
    <a href="AccessOptions.aspx?sortby=x&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">X</a>
    <a href="AccessOptions.aspx?sortby=y&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">Y</a>
    <a href="AccessOptions.aspx?sortby=z&which=<%=strWhich%>&ctl=<%=strCtl%>&lbl=<%=strLbl%>">Z</a>
    <br /><br />
    </asp:Panel>
        <input type="button" onclick="setData()" value="Select" runat="server" id="btnSelectTop" style="display:none" class="buttonclass" />
        <input type="button" onclick="window.close()" value="Close"  class="buttonclass"  style="margin-left:10px"/><br /><br />
        <br />
        <asp:GridView ID="grdData" 
            runat="server" 
            AutoGenerateColumns="false"
            ShowHeader = "false"
            OnPageIndexChanging="grdData_PageIndexChanging" OnRowDataBound="grdData_RowDataBound">
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>                         
                        
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="data"  />    
            </Columns>
            <AlternatingRowStyle BackColor="#CCCCCC" />
        </asp:GridView>
        <asp:Literal ID="ltlError" runat="server"></asp:Literal>
        <br />
        <input type="button" onclick="setData()" value="Select" runat="server" id="btnSelect" class="buttonclass"/>
        <input type="button" onclick="window.close()" value="Close"  class="buttonclass" style="margin-left:10px"/>
    </div>
    </form>
</body>
</html>
